package Hashmap;

/**
 * 判断两个字符串是不是字母异位词
 */
public class IsAnagram {
    public static void main(String[] args) {
        String s1="car";
        String s2="rab";
        IsAnagram solution=new IsAnagram();
        System.out.println(solution.isAnagram(s1,s2));

    }
    public boolean isAnagram(String s,String t){
        int[] record=new int[26];
        for(int i=0;i<s.length();i++){
            record[s.charAt(i)-'a']++;
        }
        for(int i=0;i<t.length();i++){
            record[t.charAt(i)-'a']--;
        }
        for(int count:record){
            if(count!=0){
                return false;
            }
        }
        return true;
    }
}
